home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 83
/
(Vol 83) My Disc.iso
/
Games
/
bee_game.swf
/
scripts
/
frame_12
/
DoAction.as
Wrap
Text File
|
2008-08-07
|
6KB
|
285 lines
function bunga_init(nomor)
{
var objbunga = _root["bunga" + nomor];
objbunga.hidup = true;
objbunga._alpha = 100;
objbunga.disedot = false;
objbunga.onEnterFrame = function()
{
if(!isPaused)
{
objbunga.cekbunga = false;
if(objbunga.hidup and objbunga.perimeter.hitTest(player.perimeter))
{
objbunga.cekbunga = true;
}
if(!objbunga.hidup and objbunga._alpha > 0)
{
objbunga._alpha -= 10;
}
if(!objbunga.hidup and objbunga.disedot)
{
diam = false;
}
}
};
}
function web_init(nomor)
{
var objweb = _root["web" + nomor];
objweb.hidup = true;
objweb._alpha = 100;
objweb.posisi = nomor;
objweb.onEnterFrame = function()
{
if(!isPaused)
{
objweb.cekweb = false;
if(objweb.hidup and objweb.perimeter.hitTest(player.perimeter))
{
webnomor = objweb.posisi;
player._x = objweb._x;
player._y = objweb._y;
objweb.cekweb = true;
diam2 = true;
}
if(!objweb.hidup and objweb._alpha > 0)
{
objweb._alpha -= 10;
}
}
};
}
function init()
{
pause_menu._visible = false;
isPaused = false;
stage_sound.stop();
if(suara)
{
stage_sound2.start(0,20000);
}
level = 1;
player._xscale = 130;
player._yscale = 130;
start_ani._visible = true;
completed_ani._visible = false;
start_ani.gotoAndPlay(1);
completed_ani.gotoAndStop(1);
modegame = 1;
nectarbar._alpha = 0;
webbar._alpha = 0;
timerkebal = 0;
diam = false;
diam2 = false;
jmlnectar = 0;
hpbunga = 20;
hpplayer = maxhplayer;
hppanel.gotoAndStop(hpplayer);
target = 4;
speed = 0;
topspeed = 5 + lvmove * 2;
accel = lvmove;
jumweb = 5;
jumbunga = 4;
jumpohon = 11;
jumlalat = 0;
time = 1000;
var _loc1_ = 1;
while(_loc1_ <= jumbunga)
{
bunga_init(_loc1_);
_loc1_ = _loc1_ + 1;
}
_loc1_ = 1;
while(_loc1_ <= jumweb)
{
web_init(_loc1_);
_loc1_ = _loc1_ + 1;
}
}
function looputama()
{
hppanel.gotoAndStop(hpplayer);
waktu = Math.ceil(time / 25);
tulisan = jmlnectar + " / " + target;
player.body._visible = true;
player.bintang._visible = false;
if(!(start_ani._visible or completed_ani._visible))
{
if(Key.isDown(80))
{
pause_menu._visible = false;
pause_menu._y = -600;
if(!pausepressed)
{
isPaused = !isPaused;
pausepressed = true;
}
if(isPaused)
{
pause_menu._visible = true;
pause_menu._y = -31.7;
}
}
else
{
pausepressed = false;
}
}
if(time <= 0)
{
gayamati = 2;
gotoAndStop("gameover");
delete onEnterFrame;
}
if(hpplayer <= 0)
{
gayamati = 3;
gotoAndStop("gameover");
delete onEnterFrame;
}
if(Key.isDown(77))
{
if(!musicpressed)
{
suara = !suara;
musicpressed = true;
stage_sound.stop();
if(suara)
{
stage_sound2.start(0,20000);
}
}
}
else
{
musicpressed = false;
}
if(Key.isDown(32))
{
diam = false;
}
var _loc4_ = _xmouse - player._x;
var _loc3_ = _ymouse - player._y;
angle = Math.atan2(_loc3_,_loc4_);
if(Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_) > 20)
{
speed += accel;
if(speed > topspeed)
{
speed = topspeed;
}
}
else
{
speed = 0;
}
if(!(start_ani._visible or completed_ani._visible or isPaused))
{
time--;
var _loc2_ = 1;
while(_loc2_ <= jumlalat)
{
_root["lalat" + _loc2_].play();
_loc2_ = _loc2_ + 1;
}
if(!(diam or diam2))
{
player._rotation = angle * 180 / 3.141592653589793;
player._x += Math.cos(angle) * speed;
player._y += Math.sin(angle) * speed;
player._xscale = 130;
player._yscale = 130;
}
else
{
player._xscale = 90;
player._yscale = 90;
}
if(!diam)
{
if(nectarbar._alpha > 0)
{
nectarbar._alpha -= 20;
}
timerbar = 0;
}
else
{
if(nectarbar._alpha < 100)
{
nectarbar._alpha += 20;
}
if(timerbar > 0)
{
timerbar -= 0.15;
}
else
{
timerbar = 0;
}
nectarbar.bar._xscale = timerbar / hpbunga * 100;
}
if(!diam2)
{
if(webbar._alpha > 0)
{
webbar._alpha -= 20;
}
timerbar2 = 10;
}
else
{
if(webbar._alpha < 100)
{
webbar._alpha += 20;
}
if(timerbar2 > 0)
{
timerbar2 -= 0.15;
}
else
{
timerbar2 = 0;
gayamati = 1;
gotoAndStop("gameover");
delete onEnterFrame;
}
webbar.bar._xscale = timerbar2 / 20 * 100;
}
if(timerkebal > 0)
{
player.bintang._visible = true;
timerkebal--;
if(timerkebal % 2 == 1)
{
player.body._visible = false;
}
}
}
else
{
_loc2_ = 1;
while(_loc2_ <= jumlalat)
{
_root["lalat" + _loc2_].stop();
_loc2_ = _loc2_ + 1;
}
}
_loc2_ = 1;
while(_loc2_ <= jumpohon)
{
_root["pohon" + _loc2_].daun_gerak._visible = false;
if(player.perimeter.hitTest(_root["pohon" + _loc2_].perimeter))
{
speed *= 0.5;
_root["pohon" + _loc2_].daun_gerak._visible = true;
}
_loc2_ = _loc2_ + 1;
}
}
stop();
init();
onEnterFrame = looputama;